perm filename FORMAT.RPG[UP,DOC] blob sn#615827 filedate 1981-10-02 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002
C00005 00003
C00012 ENDMK
CāŠ—;

    This is an abbreviated version of FORMAT documentation, intended
for on-line use.  It is intended as a quick reference only, and does
not contain detailed semantics.

	FORMAT destination control-string &rest args
    If DESTINATION is NIL, the formatted output is collected in a
"string";  if it is T, then the "standard default output stream" is
used, which the same as the NIL output filespec in Maclisp.
    CONTROL-STRING may be a "string" (symbol), or a list.  If it is a
list, then the elements are processed sequentially;  if an element is
a "string" it is FORMATted;  otherwise, the element should be a list,
and if the car of it is a recognized FORMAT directive, the
corresponding action is taken, and the cdr of that element is taken to
be the list of parameters to that directive.  If it isn't a recognized
directive, then it is simply EVALed, and anything it writes to the
stream STANDARD-OUTPUT will appear in the result of FORMAT.

	?FORMAT destination control-string &rest args
    This is identical to FORMAT except in the interpretation of
DESTINATION, which is interpreted as a Maclisp style filespec.  That
is, NIL means output to the standard default output stream, T means
the tty, etc.


	FERROR condition control-string &rest args
    This SIGNALs CONDITION with arguments of CONTROL-STRING, NIL, NIL,
and (spread) ARGS.  In Maclisp, if CONDITION is NIL, then
CONTROL-STRING and ARGS are given to FORMAT to get a string argument
to give as a sole argument to ERROR.  Otherwise, the SIGNAL function
is called, as it is on the Lisp Machine.  SIGNAL is not defined here.


			The Operators
Character	args used	parameters
----------------------------------------------------------------
~D		One		column-width, pad-char, comma-char
	Output arg as a decimal integer, right justified.  If the :
	modifier is given, 3-digit groups will be separated by
	comma-char.  If the @ modifier is given, then the sign will be
	output unconditionally.
~O	Same as ~D, but outputs the number in octal.
~A		One		mincol, colinc, minpad, padchar
	The argument is PRINCed, left-justified in a field mincol
	wide.  See ~< for interpretation of the other params.
~S	Same as ~A, only uses PRIN1 (recognizes the PRIN1 hook, too).
~C		One		<none>
	In Maclisp only:  this operator should not be considered to be
	properly defined yet, except insofar as ~C (no modifiers) will
	try to output the character as it is (TYO plus "C-" and/or
	"M-" for supra-ascii control and meta), and ~:@C will give a
	long-winded fully spelled out naming of the character.
~P		Hairy		<none>
	With no modifiers, this takes one arg, and if it is not 1,
	prints a lower-case "s".  The following is tentative, based on
	feedback:  If the : modifier is given, the previous arg is
	used instead (ie, it sort of does a ~-1* first).  If the @
	modifier is given, then if the arg is 1 a "y" is printed,
	otherwise "ies".
~*		Hairy		count
	This ignores count (default 1) arguments.  Count may be
	negative.
~%		None		count
	Outputs count (default 1) newlines.
~&		None		count
	Performs the FRESH-LINE operation, and then outputs count-1
	newlines.  Count defaults to 1.
~|		none		count
	Outputs count (default 1) formfeeds.  This will do a
	(CURSORPOS 'C) on TTYs.
~X		none		count
	Outputs count (default 1) spaces.
~T		none		destination, increment
	Spaces to column (plus destination (times n increment)) for
	the smallest value of N needed to pass the current column.
	Destination and increment default to 1.  This may use absolute
	cursor positioning on TTYs.
~~		none		count
	Outputs count (default 1) tildes.
~G		hairy		n
	"Goes to" the Nth argument (zero origined).  The : modifier
	makes this relative, ie identical to ~*.
~[		One		none
	This formats the ARGth alternative of the portion of the
	control string terminated by a matching ~] (ie they may be
	nested) and separated by ~;, as in
	"~[Siamese ~;Persian ~;Yu-shiang ~:;Unknown ~]Kitty".
	The alternatives are zero origined.  The : modifier given to
	~; causes the following alternative to be treated as an "else"
	clause;  eg, an argument of 1 will give "Persian Kitty", and
	an arg of anything but 0, 1, or 2 will give "Unknown Kitty".
~:[		one		none
	This is an "if" rather than a selection.  The first
	alternative string will be used if the arg is false, otherwise
	the second will be.
~;	This is the canonical control-string separater.  It is not
	itself defined, and any arguments, parameters, or modifiers it
	uses are interpreted by whoever is using it as a delimiter.
~]	Terminates ~[ or ~:[.
~<		none		mincol, colinc, minpad, padchar
	The text between the ~< and the balancing ~> is "broken into
	chunks" by delimiting ~;s, and justified in a field MINCOL
	wide.  With no modifiers, the leftmost segment will be left
	justified, and the rightmost right justified.  The : modifier
	causes spacing to be put before the leftmost segment, and the
	@ modifier after the rightmost.  If there is only one segment
	and no modifiers, then the segment will be right justified.
	MINCOL is adjusted upwards in COLINC (default 1) increments so
	that there will be at least MINPAD (default 0) pad characters
	in each of the spacing breaks.  Thus,
	    "~10<foo~;bar~>"  => "foo    bar", and
	    "~10<foobar~>"    => "    foobar", and
	    "~10:<foo~;bar~>" => "  foo  bar"
~>	Terminates a ~> construct.
~R		one		none
	~R prints its arg as a cardinal English number, eg "four";
	~:R prints it as ordinal, eg "fourth";
	~@R prints it as a Roman numeral, eg "IV";
	~:@R prints it as an ole Roman numeral, eg "IIII".